import cv2
import numpy as np
import torchvision.transforms as transforms

def convert_image(observation):
    # cv2.imshow("img_gray", observation)
    # cv2.waitKey()
    observation = cv2.cvtColor(cv2.resize(observation, (80, 80)), cv2.COLOR_BGR2GRAY)
    ret, observation = cv2.threshold(observation, 1, 255, cv2.THRESH_BINARY)
    return train_transform(np.reshape(observation, (80, 80, 1)))

train_transform = transforms.Compose([
    transforms.ToPILImage(),
    transforms.ToTensor(),  # 將圖片轉成 Tensor，並把數值normalize到[0,1](data normalization)
])